package flyweightFactory;

import concreteFlyweight.IBox;
import concreteFlyweight.LBox;
import concreteFlyweight.OBox;
import flyweight.AbstractBox;

import javax.swing.*;
import java.util.HashMap;

public class BoxFactory {

    private HashMap<String, AbstractBox> map;
    private static BoxFactory boxFactory = new BoxFactory();

    private BoxFactory(){
        map = new HashMap<String,AbstractBox>();
        map.put("I",new IBox());
        map.put("L",new LBox());
        map.put("O",new OBox());
    }

    public AbstractBox getShape(String key){
        return map.get(key);
    }

    public static BoxFactory getInstance(){
        return boxFactory;
    }
}
